package com.ddtj.demo1.pojo;

import java.util.HashMap;

public class AjaxResult extends HashMap<String,Object> {
    public static final String CODE_TAG = "code";
    public static final String MSG_TAG = "msg";
    public static final String DATA_TAG = "data";

    public AjaxResult() {
    }
    public AjaxResult(String msg){
        super.put(MSG_TAG,msg);
    }
    public AjaxResult(int code,String msg){
        super.put(CODE_TAG,code);
        super.put(MSG_TAG,msg);
    }
    public AjaxResult(int code,String msg,Object data){
        super.put(CODE_TAG,code);
        super.put(MSG_TAG,msg);
        super.put(DATA_TAG,data);
    }
    public static AjaxResult success(){
        return new AjaxResult("操作成功");
    }
    public static AjaxResult success(String msg){
        return new AjaxResult(HttpStatus.SUCCESS,msg);
    }
    public static AjaxResult success(Object data){
        return new AjaxResult(HttpStatus.SUCCESS,"操作成功",data);
    }
    public static AjaxResult success(String msg,Object data){
        return new AjaxResult(HttpStatus.SUCCESS,msg,data);
    }
    public static AjaxResult error(){
        return new AjaxResult("操作失败");
    }
    public static AjaxResult error(String msg){
        return new AjaxResult(HttpStatus.ERROR,msg);
    }
    public static AjaxResult error(Object data){
        return new AjaxResult(HttpStatus.ERROR,"操作失败",data);
    }
    public static AjaxResult error(String msg,Object data){
        return new AjaxResult(HttpStatus.ERROR,msg,data);
    }
    public static AjaxResult conflict(){
        return new AjaxResult("数据冲突");
    }
    public static AjaxResult conflict(String msg){
        return new AjaxResult(HttpStatus.CONFILICT,msg);
    }
    public static AjaxResult conflict(Object data){
        return new AjaxResult(HttpStatus.CONFILICT,"数据冲突",data);
    }
    public static AjaxResult conflict(String msg,Object data){
        return new AjaxResult(HttpStatus.CONFILICT,msg,data);
    }
}
